using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Crossborder.Common.Utility.HttpHelper;
using Crossborder.Core.Dto;
using Crossborder.Domian.Products;

namespace Crossborder.Service.Products
{
    public partial class ProductService
    {
        public async Task<HttpResponsion> QueryClassify(ProductClassifyQueryDto dto)
        {
            var data = await _ClassifyRep.GetAsync(o => o.ProClassifyId == dto.ProClassifyId && o.IsEnabled == true && o.IsDelete == false);
            var result = _Map.Map<ProductClassifyDto>(data);
            return HttpHelper.Success(result);
        }

        public async Task<HttpResponsion> QueryClassifyList(ProductClassifyQueryDto dto)
        {
            var data = await _ClassifyRep.GetListAsync(o => (o.ProClassifyId == dto.ProClassifyId || o.ProductId == dto.ProductId || o.ClassifyName == dto.ClassifyName) && o.IsEnabled == true && o.IsDelete == false);
            var result = _Map.Map<List<ProductClassifyDto>>(data);
            return HttpHelper.Success(result);
        }

        public async Task<HttpResponsion> CreateClassify(ProductClassifyInputDto dto)
        {
            var entity = _Map.Map<ProductClassify>(dto);
            entity.Create();
            var data = await _ClassifyRep.InsertAsync(entity);
            return HttpHelper.Success(data);
        }

        private async Task<ProductClassify> GetProductClassifiesByProductIdAsync(string productId)
        {
            return await _ClassifyRep.GetAsync(o => o.ProductId.Contains(productId));
        }


    }
}